import mitt from 'mitt';

class Message{
    constructor(){
        this.event=mitt();
        this.init();
    }
    init(){
        window.JSBridge.onReceiveNativeMessage=(message)=>{
            const {type,body}=message;

            this.event.emit(type,body);
        }
    }
    receive(type,callback){
        this.event.on(type,callback);
    }
    send(msg){
        window.JSBridge.onReceiveUiMessage(msg);
    }
}

export default new Message();